<style lang="less">
.sett-box {
  height: 72px;
}
</style>
<template>
<div class="page-set" id="pageSet">
  <div class="loader-base" v-if="showLoad"><div class="loader-wrap"></div></div>
  <div class="list-warp" v-for="item in todolist">
    <!-- <div class="list-ctx lineb" v-for="item.Main in item.Main"> -->
      <div class="grab-wrap" @click="goToDetail(item.Bill.Guid)">
        <div class="addr ft17"><span class="dotted"></span>{{item.Main.DepartureProvince | province}}{{item.Main.DepartureCity | city}}{{item.Main.DepartureDistrict | district}}{{item.Main.DepartureAddress}}</div>
        <div class="addr ft17"><span class="dotted org"></span>{{item.Main.ArrivalProvince | province}}{{item.Main.ArrivalCity | city}}{{item.Main.ArrivalDistrict | district}}{{item.Main.ArrivalAddress}}</div>
        <div class="statis ft14 displayflex">
          <span>{{item.Main.OrdersVolumn}}m³，{{item.Main.OrdersWeight}}kg，共{{item.Main.OrdersPKGS}}件</span>
          <div class="flex1 txt-rit" v-if="userinfo.UserBizType=='Driver'">订单收入：<em class="org">￥</em><span class="price org ft16">{{item.Main.DistributionIncome + item.Main.BusTicketAmount}}</span></div>
          <div class="flex1 txt-rit" v-if="userinfo.UserBizType=='Cargowner' || userinfo.UserBizType=='warehouse'">订单支出：<em class="org">￥</em><span class="price org ft16">{{item.Main.CarrierAmount + item.Main.InsuranceFee + item.Main.BusTicketAmount}}</span></div>
        </div>
        <div class="ft14">签收时间：<span class="org">{{item.Main.ReceiveTime | ydmhm}}</span></div>
      </div>
    <!-- </div> -->
  </div>
  <div class="noDate_page" v-if="todolist.length<=0">
    <div class="noDate_icon"><i class="iconfont icon-null"></i></div>
    未找到相关数据
  </div>
  <div class="btn-bottom" @click="gobtn" v-if="state=='1'"><div class="btn">确 认</div></div>
</div>
</template>

<script>
export default {
  data() {
    return {
      todolist: [],
      totalLength: 0,
      showLoad: false,
      count: 0,
      pageindex: 1
    };
  },
  created() {
    this.getData();
  },
  computed: {
    userinfo() {
      if (localStorage.UserInfo) {
        return JSON.parse(localStorage.UserInfo);
      }
    },
    state(){
      return this.$route.query.state
    }
  },
  watch: {},
  methods: {
    onScrollBottom() {
      this.count++;
      if (this.count == 1) {
        this.getData();
        this.$nextTick(() => {
          this.$refs.scrollerBottom.reset();
        });
      }
    },
    getData() {
      var self = this;
      var guid = this.$route.query.guid;
      self.showLoad = true;
      var query = {
        StatementGuid: guid
      };
      this.Ajax.post("GetTRTPLStatementDetail", query).then(function(resp) {
        self.showLoad = false;
        if (resp.IsSuccess) {
          self.todolist = resp.Datas;
        }
      });
    },
    gobtn() {
      var self = this;
      var guid = this.$route.query.guid;
      this.$vux.confirm.show({
        title: "提示",
        content: "是否确认对账单？",
        onConfirm() {
          var query = {
            Guid: guid
          };
          self.showLoad = true;
          self.Ajax.post("CheckTrtplstatement", query).then(function(resp) {
            self.showLoad = false;
            if (resp.IsSuccess) {
              self.$vux.toast.show({
                type: "text", //success, warn, cancel, text
                text: "已确认",
                onHide() {
                  self.$router.push({
                    path: "/user/statement"
                  });
                }
              });
            } else {
              self.$vux.toast.show({
                type: "text", //success, warn, cancel, text
                text: resp.ErrorMessage
              });
            }
          });
        }
      });
    },
    goToDetail(guid){
      this.$router.push({
        path: "/orderDetail",
        query: { id: guid }
      });
    }
  }
};
</script>